<template>
  <div>
    <div class="main">
      <h1>食谱搜索</h1>
      <div class="select-box">
        <el-input v-model="selectKey" placeholder="搜索食谱 例：土豆 鸡蛋">
          <el-button slot="append" @click="goSelect()">搜索</el-button>
        </el-input>
      </div>
      <div id="filter">
        <ul>
          <li :class="0 == filters.difficulty ? 'active' : ''" @click="chengeDifficulty(0)">全部难度</li>
          <li
            :class="k == filters.difficulty ? 'active' : ''"
            v-for="(val, k) in $gval.difficulty"
            @click="chengeDifficulty(k)"
            :key="k"
          >
            {{ val }}
          </li>
        </ul>
        <ul>
          <li :class="0 == filters.taste ? 'active' : ''" @click="chengeTaste(0)">全部口味</li>
          <li
            :class="k == filters.taste ? 'active' : ''"
            v-for="(val, k) in $gval.taste"
            @click="chengeTaste(k)"
            :key="k"
          >
            {{ val }}
          </li>
        </ul>
        <ul>
          <li :class="0 == filters.craft ? 'active' : ''" @click="chengeCraft(0)">全部工艺</li>
          <li
            :class="k == filters.craft ? 'active' : ''"
            v-for="(val, k) in $gval.craft"
            @click="chengeCraft(k)"
            :key="k"
          >
            {{ val }}
          </li>
        </ul>
        <ul>
          <li :class="0 == filters.duration ? 'active' : ''" @click="chengeDuration(0)">全部时长</li>
          <li
            :class="k == filters.duration ? 'active' : ''"
            v-for="(val, k) in $gval.duration"
            @click="chengeDuration(k)"
            :key="k"
          >
            {{ val }}
          </li>
        </ul>
      </div>
      <shipu-list :list="list"></shipu-list>
    </div>
  </div>
</template>

<script>
import ShipuList from "./ShipuList.vue";
export default {
  created() {
    this.selectKey = this.$route.params.skey;
    console.log(this.selectKey);
  },
  data() {
    return {
      selectKey: "",
      list: [1, 2, 3, 4, 5, 6, 7, 8],
      filters: {
        difficulty: 0,
        taste: 0,
        craft: 0,
        duration: 0,
      },
    };
  },
  methods: {
    chengeDifficulty(k) {
      this.filters.difficulty = k;
    },
    chengeTaste(k) {
      this.filters.taste = k;
    },
    chengeCraft(k) {
      this.filters.craft = k;
    },
    chengeDuration(k) {
      this.filters.duration = k;
    },
  },
  components: { ShipuList },
};
</script>

<style lang="less" scoped>
.main {
  width: 960px;
  margin: 0 auto;

  .select-box {
    margin: 20px auto;
    width: 960px;
    .el-button {
      width: 160px;
    }
  }
  #filter {
    margin: 2.5rem 0;

    ul {
      display: flex;
      flex-wrap: wrap;
      padding: 0;

      li {
        display: inline-block;
        padding: 0.3rem 1rem;

        color: #7180ac;
        transition: 0.5s all;
        &:hover {
                border-radius: 2px;
      color: #fff !important;
          background-color: #f05365;
          cursor: pointer;
        }
      }
    }
    .active {
      background-color: #f05365;
      border-radius: 2px;
      color: #fff !important;
    }
  }
}
</style>

